let ajaxTime = 0;
export const request=(params)=>{
    ajaxTime++;
    wx.showLoading({
      title: '加载中',
      mask:true
    })
    //定义一个公共的url
    const baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1"
    return new Promise((resolve,reject)=>{
        wx.request({
          ...params,
          url:baseUrl+params.url,
          success:(result)=>{
              resolve(result);
          },
          fail:(err)=>{
              reject(err);
          },
        //   无论成功还是失败都会调用

          complete:()=>{ 
              ajaxTime--;
              if (ajaxTime===0) {
                wx.hideLoading();
              }  
          }
        });
    })
}